#include "main.h"
double BMP_Pressure, BMP_Temperature;

uint8_t ANO_Scan = 0;
uint8_t LED_Scan = 0;
uint8_t IMU_Scan = 0;
uint8_t Batt_Scan = 0;
uint8_t IRQ_Scan = 0;
uint8_t NRF_Scan = 0;
extern BMP280_TYPE BMP280_Data;
float bmp280_temp;
float bmp280_press;
float high;
unsigned short Press,Temp,High;
extern uint8_t Run_flag;
extern uint8_t Airplane_Cmd_Flag, NRF2401_Controlflag;
extern uint8_t NRF2401_TX_DATA[TX_PAYLO_WIDTH];//NRF发送缓冲区
extern uint8_t NRF2401_RX_DATA[RX_PAYLO_WIDTH];//NRF接收缓冲区
uint8_t temp_nrf_data[32];
int main()
{
	System_Init();
	delay_ms(300);
//	static uint8_t flag = 0;
	while (1)
	{
		if (ANO_Scan)
			{//2ms发送一次上位机数据
			ANO_Scan = 0;
			printf("%s", NRF2401_RX_DATA);
		}
		if (LED_Scan)
		{//100ms更新一次LED状态，LED用于标明当前无人机状态
			LED_Scan = 0;
			LED_Run();
			if (!Airplane_Cmd_Flag && Run_flag)
			{
				RGB_LED_Runing();
			}
//			BATT_Alarm_LED();
		}
		if (IMU_Scan)
		{//MPU 10ms计算一次姿态
			IMU_Scan  = 0;
			
		}
		if (NRF_Scan)
		{//5ms发送一次2.4g通信报文
			NRF_Scan = 0;
			NRF2401_RxPacket(NRF2401_TX_DATA);
		}
		if (Batt_Scan)
		{//400ms检测一次电量
			Batt_Scan  = 0;
			LOW_Voltage_Alave();//低电量报警
		}
	}
}



